import { stringify } from 'qs';
import request from '../utils/request';

// const baseUrl = 'http://localhost';
const baseUrl = '/remote';

export async function fakeSubmitForm(params) {
  return request('/api/forms', {
    method: 'POST',
    body: params,
  });
}


export async function queryBasicProfile() {
  return request(`${baseUrl}/api/profile/basic`);
}

export async function queryAdvancedProfile() {
  return request(`${baseUrl}/api/profile/advanced`);
}

export async function queryFakeList(params) {
  return request(`${baseUrl}/api/fake_list?${stringify(params)}`);
}

export async function fakeAccountLogin(params) {
  return request(`${baseUrl}/api/login/account`, {
    method: 'POST',
    body: params,
  });
}

export async function fakeMobileLogin(params) {
  return request(`${baseUrl}/api/login/mobile`, {
    method: 'POST',
    body: params,
  });
}


export async function queryNotices() {
  return request(`${baseUrl}/api/notices`);
}



export async function removePaper(params) {
  return request(`${baseUrl}/course/del`, {
    method: 'POST',
    body: {
      ...params,
      method: 'post',
    },
  });
}

export async function editCourse(params) {
  return request(`${baseUrl}/course/edit`, {
    method: 'POST',
    body: {
      ...params,
      method: 'post',
    },
  });
}


/**
 * 查询考试信息
 * @param params
 * @returns {Promise.<Object>}
 */
export async function queryExam(params) {
  return request(`${baseUrl}/exam/index?${stringify(params)}`);
}
/**
 * 增加考试
 * @param params
 * @returns {Promise.<Object>}
 */
export async function addExam(params) {
  return request(`${baseUrl}/exam/add`, {
    method: 'POST',
    body: {
      ...params
    },
  });
}

/**
 * 更改考试
 * @param params
 * @returns {Promise.<Object>}
 */
export async function editExam(params) {
  return request(`${baseUrl}/exam/edit`, {
    method: 'POST',
    body: {
      ...params
    },
  });
}

/**
 * 查询试卷列表
 * @param params
 * @returns {Promise.<Object>}
 */
export async function queryPaper(params) {
  return request(`${baseUrl}/exam_paper/index?${stringify(params)}`);
}
/**
 * 增加试卷
 * @param params
 * @returns {Promise.<Object>}
 */
export async function addPaper(params) {
  return request(`${baseUrl}/exam_paper/add`, {
    method: 'POST',
    body: {
      ...params
    },
  });
}

/**
 * 查询课程
 * @param params
 * @returns {Promise.<Object>}
 */
export async function queryCourse(params) {
  return request(`${baseUrl}/course/index?${stringify(params)}`);
}
/**
 * 增加课程
 * @param params
 * @returns {Promise.<Object>}
 */
export async function addCourse(params) {
  return request(`${baseUrl}/course/add`, {
    method: 'POST',
    body: {
      ...params
    },
  });
}

/**
 * 删除课程
 * @param params
 * @returns {Promise.<Object>}
 */
export async function removeCourse(params) {
  return request(`${baseUrl}/course/del`, {
    method: 'POST',
    body: {
      ...params
    },
  });
}


/**
 * 查询课程
 * @param params
 * @returns {Promise.<Object>}
 */
export async function queryStudent(params) {
  return request(`${baseUrl}/student/index?${stringify(params)}`);
}
/**
 * 增加课程
 * @param params
 * @returns {Promise.<Object>}
 */
export async function addStudent(params) {
  return request(`${baseUrl}/student/import`, {
    method: 'POST',
    body: {
      ...params
    },
  });
}

/**
 * 删除课程
 * @param params
 * @returns {Promise.<Object>}
 */
export async function removeStudent(params) {
  return request(`${baseUrl}/student/del`, {
    method: 'POST',
    body: {
      ...params
    },
  });
}

/**
 * 成绩查询
 * @param params
 * @returns {Promise.<Object>}
 */
export async function queryScore(params) {
  return request(`${baseUrl}/student/index?${stringify(params)}`);
}
